<template>
  <van-search
    class="search"
    v-model="value"
    @search="search"
    placeholder="请输入网址或者查询内容"
  />
</template>

<script>
export default {
  props: {
    searchType: {
      type: String,
      default: "baidu"
    }
  },

  data() {
    return {
      value: ""
    };
  },

  methods: {
    search() {
      this.getUrlKey(this.value);
    },

    getUrlKey(name) {
      var reg = new RegExp(
        "^([hH][tT]{2}[pP]://|[hH][tT]{2}[pP][sS]://|www\\.)?(([A-Za-z0-9-~]+)\\.)+([A-Za-z0-9-~/])+$"
      );
      console.log(reg.test(name));
      return reg.test(name);
    }
  }
};
</script>

<style lang="less" scoped>
.search {
  border-radius: 26px;
}
</style>
